package kr.hkit.android_bookmgr.adapter;

import java.util.ArrayList;

import kr.hkit.android_bookmgr.R;
import kr.hkit.android_bookmgr.DTO.BookBoard;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class BoardListAdapter extends ArrayAdapter<BookBoard> { // 사용함 - 북게시판용
	private ArrayList<BookBoard> data;
	private View v;

	public BoardListAdapter(Context context, int bookboardListRow, ArrayList boardList) {
		super(context, bookboardListRow, boardList);
		this.data = boardList;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		v = convertView;
		
		if (v == null) {
			
			LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(R.layout.bookboard_list_row, null);
		}
			
		BookBoard item = data.get(position);
		
		if (item != null) {
			
			TextView book_writer = (TextView) v.findViewById(R.id.bookboard_list_writer);
			TextView book_comment = (TextView) v.findViewById(R.id.bookboard_list_comment);
			TextView book_writedate = (TextView) v.findViewById(R.id.bookboard_list_writedate);
			
			book_writer.setText("작성자 : " + item.board_writer);
			book_comment.setText(item.board_comment);
			book_writedate.setText(item.board_writedate);
		}
		return v;
	}// getView

	
}
